const bucket = new WeakMap()
const obj = { ok: true, text: '巨旭', foo: 1 }
let activeEffect = null 
const effect = (fn) => {
    activeEffect = fn
    fn()
 }
const data = new Proxy(obj, {
    get(target, key) {
        if (!activeEffect) return target[key]
        let depsMap = bucket.get(target)
        if (!depsMap) bucket.set(target, depsMap = new Map())
        let deps = depsMap.get(key)
        if (!deps) depsMap.set(key, deps = new Set())
        deps.add(activeEffect)
        return target[key]
    },
    set(target, key, newVale) {
        target[key] = newVale
        const depsMap = bucket.get(target)
        const deps = depsMap.get(key)
        deps && deps.forEach(effectFn => effectFn());
    }
})
